|
The communication mechanism for type objects is the method call which has the same semantics as a procedure/function call. The syntax of a method call:
The prefix here denotes the object which provides the method. Further this implies that a method of an object can be invoked at any location where the object itself is visible. But remember that signals, variables and constants can have different sets of methods. Due to the fact that type objects are passive, communication between type objects is blocking. To perform execution of a method, the performing object needs the computational thread of the initiator of the method call. |
To avoid runtime errors calling methods of polymorphic objects is limited to methods that are defined in the class type from which the class-wide type is build. To call methods of the actual type, the object has to be casted to the actual type. Let's take the counters of chapter 3 as an example:
VARIABLE myCounter : counter'CLASS;
The last line will cause an error during compilation, because count_down is not defined for objects of type counter. So you have to cast the object to its actual type or the class type, where the count_down method is first defined:
VARIABLE tmpCounter : up_down_counter'CLASS;
|